package com.ali.resource.ControllerPage;

import com.ali.resource.MapPage.ssl.SslMap;
import com.ali.resource.ServicePage.SslService;
import com.ali.resource.ShareTools.Result;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "ssl接口文档" , description = "ssl资源信息查询")
@RestController
@RequestMapping("/ssl")
public class SslController {

    @Autowired
    private SslService sslService;

    @Parameter(name = "bool", description = "是否下载至xlsx")
    @GetMapping("/getSslList")
    public Result getSslList(
            @RequestParam(required = true,defaultValue = "false") String bool,
            @RequestParam(required = false) String sanPrefix) throws Exception {
        List<SslMap> certList = sslService.getCertList(sanPrefix);

        if (bool.equals("true")){
            sslService.getSslExecl(certList);
        }

        return Result.builder().total(certList.size()).code(200).data(certList).build();
    }


}
